package com.edu.view;

import com.edu.ViewResult;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class DefaultViewResult extends ViewResult{

    final static String CONTENT_TYPE = "text/html;charset=utf-8";

    private Object returnVal;

    public DefaultViewResult(Object returnVal){
        this.returnVal = returnVal;
    }

    @Override
    public void execute() {
        HttpServletResponse response = getResponse();
        response.setContentType(CONTENT_TYPE);
        try {
            response.getWriter().println(returnVal);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}